﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Business.Dal;
using Business.Entity;

namespace Sahibinden.UserAction
{
    public partial class UyeEkle : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                UlkeDoldur();
            }
            
        }

        protected void btnKaydet_Click(object sender, EventArgs e)
        {
            UyeProvider up = new UyeProvider();

            Uye u = new Uye();
            u.KullaniciAdi = txtKullaniciAdi.Text;
            u.Sifre = txtSifre.Text;
            u.Adi = txtAdi.Text;
            u.Soyadi = txtSifre.Text;
            u.Email = txtEmail.Text;
            u.EvAdresi = txtAdresEv.Text;
            u.IsAdresi = txtAdresIs.Text;
            u.EvTelefon = txtTelefonEv.Text;
            u.IsTelefon = txtTelefonIs.Text;
            u.GSM = txtGsm.Text;

            up.Insert(u);
            
        }

        private void UlkeDoldur()
        {
            UlkeProvider UlkeSagla = new UlkeProvider();
            drplistUlke.DataTextField = "UlkeAdi";
            drplistUlke.DataValueField = "UlkeID";
            drplistUlke.DataSource = UlkeSagla.GetAllRows();
            drplistUlke.SelectedIndex = -1;
            drplistUlke.DataBind();
            drplistUlke.Items.Insert(0, "Bir ülke seçiniz");
        }

        protected void drplistUlke_SelectedIndexChanged(object sender, EventArgs e)
        {
            SehirProvider SehirSagla = new SehirProvider();
            drplistSehir.DataTextField = "SehirAdi";
            drplistSehir.DataValueField = "SehirID";
            drplistSehir.DataSource = SehirSagla.SehirGetir(Convert.ToInt32(drplistUlke.SelectedValue));
            drplistSehir.DataBind();
        }

        protected void drplistSehir_SelectedIndexChanged(object sender, EventArgs e)
        {
            IlceProvider IlceSagla = new IlceProvider();
            drplistIlce.DataTextField = "IlceAdi";
            drplistIlce.DataValueField = "IlceID";
            drplistIlce.DataSource = IlceSagla.IlceGetir(Convert.ToInt32(drplistSehir.SelectedValue));
            drplistIlce.DataBind();
        }
    }
}
